package com.hssy.wululuaplan.config;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * <p>Swagger配置类</p>
 * @author Mr.Hongtao
 */
@Configuration
@EnableSwagger2
public class Swagger2Config {
    @Bean
    public Docket webAllConfig(){
        return new Docket(DocumentationType.SWAGGER_2)
                // 组名
                .groupName("webAllApi") 
                .apiInfo(webAllInfo())
                .select()
                //显示当前所有接口
                .paths(PathSelectors.any())
                // 不显示/error下的接口（swagger自带的）
                .paths(Predicates.not(PathSelectors.regex("/error.*")))
                .build();

    }

    private ApiInfo webAllInfo(){
        return new ApiInfoBuilder()
                .title("乌鲁鲁 - A计划 后端接口所有文档")
                .description("本文档描述了乌鲁鲁 - A计划接口定义")
                .version("1.0")
                .contact(new Contact("史洪涛", "https://www.baidu.com", "hssymusic@163.com"))
                .build();
    }

}